package cn.edu.scau.cmi.zhonghaozheng.SingletonPattern;

public class Marshal {
	private final static int MAX_NUM_OF_MARSHAL = 10;
	private static int CUR_MARSHAL = 0;
	private static Marshal[] instances = new Marshal[MAX_NUM_OF_MARSHAL];
	private static String name;
	private Marshal(String name) {
		this.name= name;
	}
	public static Marshal getInstance(String name) {
		if (instances[CUR_MARSHAL]==null&&!name.equals("") && CUR_MARSHAL<MAX_NUM_OF_MARSHAL) {
			instances[CUR_MARSHAL] = new Marshal(name);
		}
		return instances[CUR_MARSHAL++];
	}
	public String getName() {
		return instances[CUR_MARSHAL-1].name;
	}
}
